/**
 * @a https://leetcode.cn/problems/replace-all-s-to-avoid-consecutive-repeating-characters/description/
 */

#include "common.h"

class Solution
{
public:
    string modifyString(string s)
    {
        int sz = s.size();
        for (int i = 0; i < sz; ++i)
        {
            if (s[i] == '?')
            {
                for (char ch = 'a'; ch <= 'z'; ++ch)
                {
                    if ((i == 0 || ch != s[i - 1]) && (i == sz - 1 || ch != s[i + 1]))
                    {
                        s[i] = ch;
                        break;
                    }
                }
            }
        }

        return s;
    }
};

class Solution
{
public:
    string modifyString(string s)
    {
        int sz = s.size();
        for (auto ch : s)
        {
            if (ch == '?')
            {
                for (char i = 'a'; i < 'z'; ++i)
                {
                    if((i == 0 || ch != s[i - 1]) && ( i == sz - 1 || ch != s[i + 1]))
                    {
                        s[i] = ch;
                        break;
                    }
                }
            }
        }
        return s;
    }
};